#ifndef IAGENT_H
#define IAGENT_H
//****************************************************************************
//**
//**    $Workfile: IAgent.h $
//**
//**    Copyright (c) 2007 Dale Freya
//**
//**    $Author: Dfreya $
//**    $Date: 2/01/07 5:32p $ 
//**    $Revision: 2 $
//**
//****************************************************************************
#include <Clarity/ForwardDeclarations.h>
#include <Clarity/Platform/DLLInterface.h>
#include <Clarity/Utils/SharedPtr.h>
#include <Clarity/Math/Vector2.h>
#include <Clarity/Math/Area.h>
#include <Clarity/Math/AARect.h>
#include <vector>

namespace AIHarness
{
   using namespace Clarity;

   /**
   * This structure describes an entity detected by an agent's sensors
   */
   struct SensorData
   {
      std::string name;          // The name of the entity detected
      std::string type;          // The type of the entity detected
      Vector2 position;          // The position of the entity detected
      Area area;                 // The bounding area of the entity detected
   };

   /**
   * This enumeration describes the action that the agent is taking this step.
   */
   enum Action
   {
      ACTION_SCAN,   /**< The agent is scanning this frame. */
      ACTION_FIRE    /**< The agent is firing this frame. */
   };

   enum GameMode
   {
      GAME_MODE_BOTMATCH,
      GAME_MODE_RABBITHUNT
   };

   /**
   * This structure contains constants relating to the agent and its environment.
   */
   struct AgentInitData
   {
      SceneManager *sceneManager;   /**< In debug builds the scene manager is passed in */
      float interval;               /**< The seconds between agent steps */
      float maxHealth;              /**< The health when the agent is fully healed */
      std::string levelName;        /**< The name of the level in which the agent is active */
      float scanAngleRadians;       /**< The angle of the agent's long range scanner */
      float beamSpeed;              /**< The speed at which the agent's beams travel at */
      std::vector<AARect> walls;    /**< The walls of the maze */
      AARect arenaBounds;           /**< The rectangle defining the bounds of the arena */
      GameMode gameMode;            /**< The mode of the game in which the bot is playing */
   };

   /**
   * This structure contains state information about the current frame.
   */
   struct AgentStateIn
   {
      Vector2 velocity;                    /**< current velocity of agent */
      Vector2 lookDir;                     /**< direction of scanning and shooting */
      Vector2 position;                    /**< current position of agent */
      float health;                        /**< current health of agent */
      std::vector<SensorData> sensorData;  /**< current sensor data */
	  int shotHit;
   };

   /**
   * This structure contains instructions by the agent for the current frame.
   */
   struct AgentStateOut
   {
      float power;      /**< engine force between 0 and 1 */
      Vector2 moveDir;  /**< direction in which engine force is applied */
      Vector2 lookDir;  /**< direction of scanning and shooting */
      Action action;    /**< action to take */
   };

   /**
   * This class defines the interface for an agent.
   */
   class IAgent : public DLLInterface
   {
   public:
      /**
      * This member is the agent's think function.
      *
      * @param agentStateIn
      *     State information about the current frame.
      * @param agentStateOut
      *     Instruction data from the agent about it's actions this frame.
      */
      virtual void Step(
         const AgentStateIn &agentStateIn, 
         AgentStateOut &agentStateOut) = 0;
   };

   /**
   * This function signature is used to create an agent from a plugin.  Agent 
   * plugins must provide the CreateAgentFunc in an extern "C" block.
   */
   typedef void (* CreateAgentFunc)(SharedPtr<IAgent> &, AgentInitData);
}

//****************************************************************************
//**
//**    END INTERFACE
//**
//****************************************************************************
#endif
